<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.util.*"%>
<%@ page import="vlms.bean.Movie"%>
<%
	Movie[] movieList=(Movie[])request.getAttribute("MovieList");
	
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<script type="text/javascript">
     function validate(){
         
         if(document.Form.search_text.value=="")
         {
      alert("Entry required. Enter keyword to search");
      document.Form.search_text.focus();
      return false;
         }
         return true;
     }
     </script>
<title>SearchMovie</title>
</head>
<body>
<table width="100%">
<%@ include file="/header.jsp" %>

<tr valign="top"><td align="center" height="300px">
<table width="100%">

<tr valign="top" height="50px">
<td align="center">
<%@ include file="/headerLinks.jsp" %>
</td>
</tr>
<tr><td align="center" height="40px" colspan="2" valign="top"><h3>Search and Delete a Movie</h3></td></tr>
<% if(request.getAttribute("message") != null) { %>
<tr><td align="center" style="color:red"><%= request.getAttribute("message") %></td></tr>
<% } %>
 <form id="Form" name="Form" method="POST" action="SearchMovie" onsubmit="return validate();">
<table>
<BR><BR>
<tr><td>
<H2>Search Movie </H2>
</td></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr>
<td>
Search By:
<SELECT NAME="search" id ="search">
<OPTION VALUE='movieName' selected="selected">Movie Name</OPTION>
<OPTION VALUE='movieBanner'>Movie Banner</OPTION>
<OPTION VALUE='movieCategory'>Movie Category</OPTION>
</SELECT> 
</td>
<td>
Search: 

  <input type="text" name="search_text" id="search_text" value="">
  </td>
  <td>

 <input type="submit" name="Submit" value="Search">
 </td></tr>
 <tr height="200px"></tr>
</table>
 </form>
 </center>

<table width="100%">

<tr valign="top" height="50px">
<td align="center">
<%@ include file="/headerLinks.jsp" %>
</td>
</tr>

<% if(request.getAttribute("message") != null) { %>
<tr><td align="center" style="color:red"><%= request.getAttribute("message") %></td></tr>
<% } %>

		<div class="inputColumn" id="movieList"
			style="text-align: center; border: thin; margin: auto;">
			<table border="1">
				
				<%
				if(movieList!=null)
				{
						
						
				%>
				<tr>
					<td align="right">
					<label name="select" style="size: 30;">Select to Perform operation</label>
					</td>
					<td align="right">
					<label name="moviename" style="size: 30;">Movie Name</label>
					</td>
					<td align="right">
					<label name="moviebanner" style="size: 30;">Movie Banner</label>
					</td>
					<td align="right">
					<label name="moviecategory" style="size: 30;">Movie Category</label>
					</td>
					<td align="right">
					<label name="releasedate" style="size: 30;">Release Date</label>
					</td>
					<td align="right">
					<label name="rentamount" style="size: 30;">Rent Amount</label>
					</td>
					
				</tr>
				
				<%
				
				for(Movie movie: movieList)
				{
					if(movie.getCopiesavailable()>0)
					{
				%>
				
				<form name="row" method="post" action="ListPersonForMovie">
				<table border="1">
				<tr bordercolor="red" style="border-style: none" bordercolor="white">
				<td>
				<input type="radio"
						value='<%=movie.getMovieid()%>'
						name="movieId" /></td>
					<td bordercolor="red" bordercolor="white"><label
						name="movieName" style="size: 30;"><%=movie.getMoviename()%></label>
					</td>
					<td bordercolor="red" bordercolor="white"><label
						name="movieBanner" style="size: 30;"><%=movie.getMoviebanner()%></label>
					</td>
					<td bordercolor="red" bordercolor="white"><label
						name="movieCategory" style="size: 30;"><%=movie.getCategory()%></label>
					</td>
					<% Calendar c= movie.getReleasedate();
					java.util.Date d=new java.util.Date(c.getTimeInMillis());
					
					
					%>
					
					<td bordercolor="red" bordercolor="white"><label
						name="releaseDate" style="size: 30;"><%=new SimpleDateFormat("yyyy-mm-dd").format(d)%></label>
					</td>
					<td bordercolor="red" bordercolor="white"><label
						name="rentAmount" style="size: 30;"><%=movie.getRentamount()%></label>
					</td>
					<td>
					<input type="hidden" name="hidden" value='<%=movie.getMovieid()%>' />
					<input type="submit" value='Delete' name="submit" />
					<input type="submit" value='List Person' name="submit" />
					<input type="submit" value='Update' name="submit" />
				</tr>
				</table>
				</form>
				
				<%
				}
				}
				
				}
				%>
      </table>
      </div>
     

</table>
</td>
</tr> 	
</table>
</td>
</tr>
<%@ include file="/bottom.html" %>
</table>
</body>
</html>